package com.nervenets.shopping.service.impl;

import com.nervenets.general.jwt.util.JwtUtils;
import com.nervenets.general.model.SecurityUser;
import com.nervenets.general.service.GlobalSecurityService;
import lombok.extern.slf4j.Slf4j;

import java.util.Set;

/**
 * 2020/6/28 13:54 created by Joe
 **/
@Slf4j
@com.alibaba.dubbo.config.annotation.Service(version = "1.0.0")
@org.springframework.stereotype.Service
public class GlobalSecurityServiceImpl implements GlobalSecurityService {
    @Override
    public SecurityUser getUserInfo(String token, String license) {
        return JwtUtils.getUser(token, license);
    }

    @Override
    public String getToken(SecurityUser securityUser, String license) {
        return JwtUtils.getToken(securityUser, license);
    }

    @Override
    public void clearToken(long userId) {
        JwtUtils.clearToken(userId);
    }

    @Override
    public void authorize(String token, String license, Set<String> menus, Set<String> permissions) {
        JwtUtils.authorize(token, license, menus, permissions);
    }

    @Override
    public void logout(String token, String license) {
        JwtUtils.logout(token, license);
    }
}
